package xy.http.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import xy.http.entity.User;

@RestController
public class DemoController {


    @GetMapping("get")
    public String demo() {
        return "this is get request";
    }

    @GetMapping("getParams")
    public String getParams(String userName, String passWord) {
        return "my name is " + userName + " , my pwd is " + passWord;
    }

    /**
     * multipart/form-data表单请求
     *
     * @return
     */
    @PostMapping("postFormData")
    public String postFormData() {
        return "this is get request";
    }


    @PostMapping("post")
    public String post(String userName, String passWord) {
        return "my name is " + userName + " , my pwd is " + passWord;
    }


    /**
     * post json
     *
     * @param user
     * @return
     */
    @PostMapping("jsonPOst")
    public User jsonPOst(@RequestBody User user) {
        return user;
    }

}
